<html>
	<head><title>Regions</title></head>
	<body>
		<center><h1>Regions</h1><br>
		<br>
		<table border="1">
		<tr>
			<th>Region No.</th>
			<th>Region Name</th>
			<th>Captain No.</th>
			<th>Headquarters</th>
			<th>President Name</th>
			<th>Wins</th>
			<th>Losses</th>
			<th>Ties</th>
		</tr>
		<?php
			$con = mysql_connect("oniddb.cws.oregonstate.edu","rundej-db","Hp2tYI0CxEY4U9J9");
			if (!$con)
			{
				die('Could not connect: ' . mysql_error());
			}
			mysql_select_db('rundej-db',$con);
			$result = mysql_query("SELECT * FROM Region");	
			while ($row = mysql_fetch_array($result))
			{
				echo "<tr>";
				echo "<td>" . $row['Region_No'] . "</td>";
				echo "<td>" . $row['Region_Name'] . "</td>";
				echo "<td>" . $row['Captain'] . "</td>";
				echo "<td>" . $row['Headquarters'] . "</td>";
				echo "<td>" . $row['President_Name']. "</td>";
				echo "<td>" . $row['Num_Wins'] . "</td>";
				echo "<td>" . $row['Num_Losses'] . "</td>";
				echo "<td>" . $row['Num_Ties'] . "</td>";
				echo "</tr>";
			}
			mysql_close($con);
		?>
		</table>
		<h2>Add Region</h2><br>
		<table cellpadding = "10">
			<tr>
				<th><center>Region No.</center></th>
				<th><center>Region Name</center></th>
				<th><center>Headquarters</center></th>
				<th><center>President</center></th>
			</tr>
			<tr>
			<form action = "addRegions.php" method = "post">
				<td><input type = "text" name = "regionNo"></td>
				<td><input type = "text" name = "regionName"></td>
				<td><input type = "text" name = "headquarters"></td>
				<td><input type = "text" name = "presName"></td>
			</tr>
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td><center><input type = "submit" name = "addRegion" value = "Add Region"></center></td>
			</tr>
			</form>
		</table>
		<h2>Update Captain</h2>
		<table cellpadding = "10">
		<tr>
			<th>Region Name</th>
			<th>Captain Last Name</th>
		</tr>
		<tr>
			<form action = "updateCaptain.php" method = "post">
			<td><input type = "text" name = "rname"></td>
			<td><input type = "text" name = "cname"></td>
		</tr>
			<td></td>
			<td><input type = "submit" name = "updateCap" value = "Update Captain"></td>
			</form>
		</table>
		<h2>Enter Match</h2>
		<table cellpadding = "10">
			<tr>
				<th>Region 1</th>
				<th>Region 2</th>
			</tr>
			<tr>
			<form action = "enterMatch.php" method = "post">
				<td><input type = "text" name = "region1"></td>
				<td><input type = "text" name = "region2"></td>
			</tr>
			<tr>
				<th colspan = 3>Winner</th>
			</tr>
			<tr>
				<th>Region 1</th>
				<th>Region 2</th>
				<th>Tie</th>
			</tr>
			<tr>
				<td><center><input type = "radio" name = "winner" value = "Region 1"></center></td>
				<td><center><input type = "radio" name = "winner" value = "Region 2"></center></td>
				<td><center><input type = "radio" name = "winner" value = "Tie"></center></td>
			</tr>
			<tr>
				<td align = "right"><input type = "submit" name = "enterMatch" value = "Enter Match"/></td>
			</tr>
			</form>
		</table>
		<br>
		<center><h2>View Win-Loss-Tie Record</h2><br><br>
			<h3>Region Name: </h3>
			<form action = "getRecord.php" method = "post">
				<input type = "text" name = "region"/>
				<input type = "submit" name = "record" value = "Record"/>
			</form>
		</center>
		<br>
		<center>
			<a href = "index.php">Home</a>	
			<a href = "umpires.php">Umpires</a>	
			<a href = "players.php">Players</a>
		</center>	
	</body>
</html>
